package com.nana.petadventure.utils
{
	import com.nana.petadventure.model.obj.HarmFlyerObj;
	import com.nana.petadventure.model.obj.FlyerObj;

	public class GameLogicManager
	{
		private var _instance:GameLogicManager;
		private var _currentHp:int;
		
		public function GameLogicManager()
		{
			if(_instance == null)
				super();
			else
			{
				throw new Error("实例化单例类出错-GameLogicManager");
			}
		}
		
		public static function getInstance():GameLogicManager {
			if(_instance == null) {
				_instance = new GameLogicManager();
			}
			return _instance;
		}
		
		public function generateObject():FlyerObj {
			
		}
		
		public function hitObject(flyer:FlyerObj):Boolean {
			if(flyer is HarmFlyerObj) {
				this.reduceHp((HarmFlyerObj)flyer.damage);
			}
		}
		
		private function reduceHp(dHp:int):void {
			_currentHp -= dHp;
			if (_currentHp <= 0) {
				_currentHp = 0;
				this.gameOver();
			}
		}
		
		private function increaseHp(dHp:int):void {
			_currentHp += dHp;
			
		}
		
		public function stageClear():void {
			
		}
		
		public function gameOver():void {
			
		}
	}
}